#define _CRT_SECURE_NO_WARNINGS  1
#include<iostream>
#include <string>
#include <algorithm>
using namespace std;

/*
class Test {
public:
	int a;
	int b;
	virtual void fun() {}
	Test(int temp1 = 0, int temp2 = 0)
	{
		a = temp1;
		b = temp2;
	}
	int getA()
	{
		return a;
	}
	int getB()
	{
		return b;
	}
};
int main()
{
	Test obj(5, 10);
	// Changing a and b
	int* pInt = (int*)&obj;
	*(pInt + 0) = 100;
	*(pInt + 1) = 200;
	cout << "a = " << obj.getA() << endl;
	cout << "b = " << obj.getB() << endl;
	cout << "sizeof = " << sizeof(obj) << endl;
	return 0;
}

*/

/*
class A
{
public:
	void print()
	{
		cout << "A:print()";
	}
};
class B : private A
{
public:
	void print()
	{
		cout << "B:print()";
	}
};
class C : public B
{
public:
	void print()
	{
		A::print();
	}
};
int main()
{
	C b;
	b.print();
}

*/


int main()
{
	int n;
	cin >> n;
	int count = 0;
	for (int i = 1; i <= n; i++)
	{
		int ret = 0;
		for (int j = 1; j < i; j++)
		{
			if (i % j == 0)
			{
				ret += j;
			}
		}

		if (ret == i)
		{
			count++;
		}
	}

	cout << count;
	return 0;
}



string FindMax(const string& str)
{
	if (str.find("joker JOKER") != string::npos)
		return "joker JOKER";

	int dash = str.find('-');
	string card1 = str.substr(0, dash);
	string card2 = str.substr(dash + 1);

	int card1_count = count(card1.begin(), card1.end(), ' ') + 1;
	int card2_count = count(card2.begin(), card2.end(), ' ') + 1;

	string card1_first = card1.substr(0, card1.find(' '));
	string card2_first = card2.substr(0, card2.find(' '));

	if (card1_count == card2_count)
	{
		string s = "345678910JQKA2jokerJOKER";
		if (s.find(card1_first) > s.find(card2_first))
			return card1;
		return card2;
	}

	if (card1_count == 4)
		return card1;
	else if (card2_count == 4)
		return card2;
	return "ERROR";
}

int main() {
	string str, res;
	while (getline(cin, str)) {
		res = FindMax(str);
		cout << res << endl;
	}
	return 0;
}